﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using WanDa.IBll;
using WanDa.Bll;

namespace WanDa.BllContainer
{
    public class Container
    {
        public static IContainer container = null;
        public static T resolve<T>()
        {
            try
            {
                if (container == null)
                {
                    Initialise();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return container.Resolve<T>();
        }
        public static void Initialise()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<UsersBll>().As<IUsersBll>().InstancePerLifetimeScope();
            builder.RegisterType<ProjectAppBll>().As<IProjectAppBll>().InstancePerLifetimeScope();
            container = builder.Build();
        }
    }
}
